<script type="text/javascript" src="http://www.ztree.me/v3/js/jquery.ztree.core-3.5.js"></script>
<link href="http://www.ztree.me/v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css">
<div class="filter-bar">
<form action="__CONTROLLER__/index" method="post" >
	<div class="view">
		<div class="row clearfix">
			<div class="col-md-4 column ui-sortable">
			    <label class="col-sm-3 control-label" style="margin-top:5px;">代理商</label>
			    <div class="col-sm-6" style="position:relative;">
			      <input type="text" readonly="readonly" id="agentName" class="form-control" name="agentName" placeholder="" value="{$params.agentName}">
			      <input type="hidden" readonly="readonly" id="agentId" class="form-control" name="agentId" placeholder="" value="{$params.agentId}">
				  <div id="menuContent" class="menuContent" style="display:none; position: absolute;z-index: 19999;border: 1px solid #ccc; background: #fff;width: 100%;overflow: auto; max-height: 300px;">
					  	<ul id="treeDemo" class="ztree" style="margin-top:0; width:160px;"></ul>
				  </div>
			    </div>
			</div>
			<div class="col-md-4 column row ui-sortable">
			    <label class="col-sm-3 control-label" style="margin-top: 8px;">显示越级订单</label>
			    <div class="col-sm-9" style="  padding-top: 8px;">
			    	<input name="showSubOrder" type="checkbox" value="1" {$params['showSubOrder']?"checked='checked'":''} />
			    </div>
			</div> 
			<div class="col-md-4 column row ui-sortable">
			    <label class="col-sm-3 control-label" style="margin-top: 8px;">订单类型</label>
			    <div class="col-sm-9">
				      <select class="form-control" style="float: left;margin-right: 10px;"  name="type">
		              {$orderTypesOptions}
		              </select>
			    </div>
			</div> 
		</div>
		<div class="row clearfix">
			<div class="col-md-3 column ui-sortable">
			    <div class="col-sm-9">
			       <input type="submit" class="btn btn-info submit" value="搜索"/>
			    </div>
			</div>
		</div>
	</div>
</form>
</div>
<hr/>

<table class="table table-hover">
 <thead>
  <tr>
   <th>ID</th>
   <th>订单编号</th>
   <th>总额</th>
   <th>下单时间</th>
   <th>收货人</th>
   <th>收货人电话</th>
   <th>订单状态</th>
   <th>操作</th>
  </tr>
 </thead>
 <tbody>
  <volist name="productOrderLists" id="vo">
   <tr>
    <td>{$vo.id}</td>
    <td>{$vo.order_id}</td>
    <td>{$vo.goods_amount}</td>
    <td>{$vo.create_time|date="Y-m-d H:i:s", ###}</td>
    <td>{$vo.consignee}</td>
    <td>{$vo.tel}</td>
    <td>{$vo.orderShowStatus}</td>
    <td>
      <a class="btn btn-info btn-xs" href="__CONTROLLER__/detials/id/{$vo.id}">订单详情</a>
    </td>
   </tr>
  </volist>
 </tbody>
</table>
<div class="pagination">{$pagination}</div>

<SCRIPT type="text/javascript">
	<!--
	var setting = {
		view: {
			dblClickExpand: false
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			beforeClick: beforeClick,
			onClick: onClick
		}
	};

	var zNodes = {$agentJson};

	function beforeClick(treeId, treeNode) {
		var check = (treeNode && !treeNode.isParent);
		return true;
	}
	
	function onClick(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
		nodes = zTree.getSelectedNodes(),
		v = "";
		nodes.sort(function compare(a,b){return a.id-b.id;});
		for (var i=0, l=nodes.length; i<l; i++) {
			v += nodes[i].name + ",";
		}
		if (v.length > 0 ) v = v.substring(0, v.length-1);
		var cityObj = $("#agentName");
		cityObj.attr("value", v);
		$("#agentId").val(nodes[nodes.length-1]["id"]);
	}

	function showMenu() {
		var cityObj = $("#agentName");
		var cityOffset = cityObj.offset();
		$("#menuContent").slideDown("fast");
		$("body").bind("mousedown", onBodyDown);
	}
	function hideMenu() {
		$("#menuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}

	$(document).ready(function(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		$("#agentName").click(function() {
			showMenu();
		});
	});
	//-->
</SCRIPT>